package com.cszy.yydqbfq.bean

import org.litepal.LitePal
import org.litepal.annotation.Column
import org.litepal.crud.LitePalSupport


// 歌单实体类
data class SongListBean(
    @Column(unique = true)
    var id: Long = 0,
    var name: String = "",
    var cover: String = "",
    var isLocal: Boolean = false,
    var createTime: Long = System.currentTimeMillis(),
    var isSelected: Boolean = false, // 用于标记是否被选中
    var localCount:Int=0   //新增count字段用来记录本地音乐个数
) : LitePalSupport() {
    // 一对多关系：一个歌单有多首歌曲
    val songs: List<Song> by lazy {
        LitePal.where("songlistbean_id = ?", id.toString()).find(Song::class.java)
    }

    val songCount: Int
        get() = songs.size
}

// 歌曲实体类
data class Song(
    var id: Long = 0,
    var title: String = "",
    var artist: String = "",
    var cover: String = "",
    var duration: Long = 0,
    var uri:String = "",//播放地址
    @Column // 只添加注解，不使用name属性
    var songlistbean_id: Long = 0 // 直接使用LitePal默认的外键命名
) : LitePalSupport()